package com.yipei.business.service.impl;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import com.yipei.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.yipei.business.mapper.MlTradeAccountFinancingApplyMapper;
import com.yipei.business.domain.MlTradeAccountFinancingApply;
import com.yipei.business.service.IMlTradeAccountFinancingApplyService;

/**
 * 融资申请Service业务层处理
 *
 * @author yipei
 * @date 2024-12-23
 */
@Service
public class MlTradeAccountFinancingApplyServiceImpl implements IMlTradeAccountFinancingApplyService
{
    @Autowired
    private MlTradeAccountFinancingApplyMapper mlTradeAccountFinancingApplyMapper;

    /**
     * 查询融资申请
     *
     * @param id 融资申请主键
     * @return 融资申请
     */
    @Override
    public MlTradeAccountFinancingApply selectMlTradeAccountFinancingApplyById(Long id)
    {
        return mlTradeAccountFinancingApplyMapper.selectMlTradeAccountFinancingApplyById(id);
    }

    /**
     * 查询融资申请列表
     *
     * @param mlTradeAccountFinancingApply 融资申请
     * @return 融资申请
     */
    @Override
    public List<MlTradeAccountFinancingApply> selectMlTradeAccountFinancingApplyList(MlTradeAccountFinancingApply mlTradeAccountFinancingApply)
    {
        return mlTradeAccountFinancingApplyMapper.selectMlTradeAccountFinancingApplyList(mlTradeAccountFinancingApply);
    }

    /**
     * 新增融资申请
     *
     * @param mlTradeAccountFinancingApply 融资申请
     * @return 结果
     */
    @Override
    public int insertMlTradeAccountFinancingApply(MlTradeAccountFinancingApply mlTradeAccountFinancingApply)
    {
        Date now = new Date();
        // 定义日期格式
        SimpleDateFormat sdf1 = new SimpleDateFormat("yyyyMMddHHmmss");
        // 格式化
        String formattedDate = sdf1.format(now);
        mlTradeAccountFinancingApply.setCreateTime(DateUtils.getNowDate());
        mlTradeAccountFinancingApply.setPzDh("PZ"+formattedDate);
        return mlTradeAccountFinancingApplyMapper.insertMlTradeAccountFinancingApply(mlTradeAccountFinancingApply);
    }

    /**
     * 修改融资申请
     *
     * @param mlTradeAccountFinancingApply 融资申请
     * @return 结果
     */
    @Override
    public int updateMlTradeAccountFinancingApply(MlTradeAccountFinancingApply mlTradeAccountFinancingApply)
    {
        mlTradeAccountFinancingApply.setUpdateTime(DateUtils.getNowDate());
        return mlTradeAccountFinancingApplyMapper.updateMlTradeAccountFinancingApply(mlTradeAccountFinancingApply);
    }

    /**
     * 批量删除融资申请
     *
     * @param ids 需要删除的融资申请主键
     * @return 结果
     */
    @Override
    public int deleteMlTradeAccountFinancingApplyByIds(Long[] ids)
    {
        return mlTradeAccountFinancingApplyMapper.deleteMlTradeAccountFinancingApplyByIds(ids);
    }

    /**
     * 删除融资申请信息
     *
     * @param id 融资申请主键
     * @return 结果
     */
    @Override
    public int deleteMlTradeAccountFinancingApplyById(Long id)
    {
        return mlTradeAccountFinancingApplyMapper.deleteMlTradeAccountFinancingApplyById(id);
    }
}
